//package com.moon.game.command.guest.mission;
//
//import java.util.ArrayList;
//import java.util.List;
//
//import com.moon.game.command.BaseCmd;
//import com.moon.game.command.RequestSession;
//import com.moon.game.constants.Constants;
//import com.moon.game.constants.ErrorCode;
//import com.moon.game.exception.GException;
//import com.moon.game.service.MissionService;
//import com.moon.game.service.PlayerService;
//import com.moon.game.vos.ErrorMsg;
//import com.moon.game.vos.PlayerVo;
//import com.moon.game.vos.PlayerVo.MyMission;
//
///**
// * @description 查看今日任务或者刷新任务
// * @author Ranger 作者 E-mail:haozi000005@163.com
// * @version 创建时间：2012-8-2 下午3:49:38
// */
//public class ShowTodayMissionsCmd extends BaseCmd {
//
//	@Override
//	protected void runOnce(RequestSession req) throws GException {
//		switch (req.getStatus()) {
//			case STATU_INIT:
//				doInit(req);
//				break;
//			case STATU_CHECK:
//				doCheckSelf(req);
//				break;
//			case STATU_RETURN:
//				doResponse(req);
//				break;
//			default:
//				break;
//		}
//
//	}
//
//	@Override
//	protected void doResponse(RequestSession req) throws GException {
//		String[] ps = req.getClientRequest().getPs();
//		if (ps == null) {
//			doResponsePsError(req);
//			return;
//		}
//		PlayerVo player = req.getPlayer();
//		List<MyMission> myMissions = player.getMissionList();
//		if (myMissions == null || myMissions.size() == 0) {
//			// 玩家当前没有任务
//			MissionService.assignMission(player, 0);
//		}else {
//			if (ps != null) {
//				Integer refreash = Integer.parseInt(ps[0]);
//				if (refreash == null) {
//					doResponsePsError(req);
//					return;
//				}
//				if (refreash == 1) {
//					boolean hasUnfinishedMission = false;
//					for (MyMission mission : myMissions) {
//						if (mission.getStatu() == 0) {
//							hasUnfinishedMission = true;
//							break;
//						}
//					}
//					if (!hasUnfinishedMission) {
//						doResponseErrorMsg(req,ErrorMsg.build(ErrorCode.ERR_FINISHED_ALL_MISSION, "你今天的任务已经全部完成了，明天会自动更新！"));
//						return;
//					}
//				
//					boolean minusStatu = PlayerService.minusGold(player.getSid(), player.getId(), Constants.REFRESH_MISSION_PRICE);
//					if (!minusStatu) {
//						doResponseErrorMsg(req,ErrorMsg.build(ErrorCode.ERR_NO_GOLD, "更换任务需要金币" + Constants.REFRESH_MISSION_PRICE + ",你的金币不足！"));
//						return;
//					}
//					MissionService.assignMission(player, 0);
//				}
//			}
//		}
//		myMissions = player.getMissionList();
//		List<Integer> missionIds = new ArrayList<Integer>();
//		for (MyMission mission : myMissions) {
//			if (mission.getStatu() == 1) {
//				// 已经完成的任务不返回显示
//				continue;
//			}
//			missionIds.add(mission.getMissionId());
//		}
//		req.setVO("mission_ids", missionIds);
//		req.setVO("refresh_price", Constants.REFRESH_MISSION_PRICE);
//		response(req, req.getClientResponse());
//	}
//
//}
